-- less_damage_hit
-- created by wangy
-- 受创x%概率减少x%所受到的伤害，对BOSS效果减半（战斗大师专用）
-- 勿挪用，冈布奥专属

return {
    apply = function(prop, baseValue)
        return prop[3];
    end,

    -- 攻击时触发
    trigger = function(who, prop, arg)
        local damage = arg["damage"];
        -- 概率不满足
        if DungeonM.getRandSeed("LESS_HIT") % 1000 >= prop[3] then
            return damage;
        end
        local source = arg["source"];
        local rate = tonumber(prop[2]);
        if source.type == OBJECT_TYPE_MONSTER then
            if source:isBoss() then
                rate = math.modf(rate / 2);
            end
        end

        damage = damage - math.modf(rate * damage / 1000);

        -- 触发特技发动事件
        EventMgr.fire(event.SPECIAL_SKILL_TRIGGER, { propId = prop[1] });

        return damage;
    end,

    record = function(target, prop, path)
        return false;
    end
};
